package com.control.qct.businesssteward.adapter;

import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.control.qct.businesssteward.R;
import com.control.qct.businesssteward.model.OpenOrderModel;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.control.qct.businesssteward.utils.GlideUtil;

import java.util.List;

/**
 * Created by Administrator on 2017/12/1 0001.
 */

public class SelectGoodsAdapter extends BaseQuickAdapter<OpenOrderModel.DatasBean, BaseViewHolder> {
    private int mPosition;

    public SelectGoodsAdapter(@Nullable List<OpenOrderModel.DatasBean> data) {
        super(R.layout.rv_select_goods_item, data);
    }

    @Override
    protected void convert(BaseViewHolder holder, OpenOrderModel.DatasBean item) {
        GlideUtil.loadImage(mContext,item.getImageSmallUrl(), (ImageView) holder.getView(R.id.iv_goods_picture));
        holder.setText(R.id.tv_goods_name, item.getTitle()).setText(R.id.tv_goods_code, "条码：" + item.getBarcode())
                .setText(R.id.tv_discount_price, "￥ " + item.getPreferentialPrice()).setChecked(R.id.cb_goods_select,
                mPosition == holder.getAdapterPosition());
        holder.addOnClickListener(R.id.cb_goods_select);
    }

    public void setPosition(int position) {
        this.mPosition = position;
        notifyDataSetChanged();
    }
}
